package com.mxx.common.flow;

/**
 * @author: mxx
 * @date: 2022/1/4
 * @time: 13:16
 * @Description: 描述信息
 */
public class FlowManagerBuilder {

    private DefaultFlowManager flowManager;
    private boolean reflect;

    public FlowManagerBuilder(boolean reflect) {
        this.reflect = reflect;
        this.flowManager = new DefaultFlowManager();
    }

    public static FlowManagerBuilder build() {
        return new FlowManagerBuilder(false);
    }

    public static FlowManagerBuilder reflectBuild() {
        return new FlowManagerBuilder(true);
    }

    public FlowModuleBuilder register(FlowEvent flowEvent) {
        FlowModule flowModule = reflect ? new ReflectFlowModule(flowEvent) : new FlowModule(flowEvent);
        flowManager.register(flowModule);
        return new FlowModuleBuilder(this, flowModule);
    }

    public FlowManager complete() {
        return this.flowManager;
    }

}
